/** 
 * File-Name:NeoCrawlerConfiguration.java
 *
 * Created on 2011-4-16 下午02:54:37
 * 
 * @author: Neo (neolimeng@gmail.com)
 * Software Engineering Institute, Peking University, China
 * 
 * Copyright (c) 2009, Peking University
 * 
 *
 */
package org.neocrawler.util;

/**
 * Description:Configurations of NeoCrawler
 * 
 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
 *          University, China
 * @version 1.0 2011-4-16 下午02:54:37
 */
public class Configuration {
	public static final int DEFAULT_CONNECT_TIMEOUT = 10000;
	public static final int DEFAULT_GET_REQUEST_TIMEOUT = 30000;
	public static final int DEFAULT_THREAD_POOL_SIZE = 10;
	public static final boolean DEFAULT_USE_PROXY_OR_NOT = false;
	public static final long DEFAULT_SLEEP_TIME = 5000;
	public static final long DEFAULT_SLEEP_TIME_RANDOM = 5000;
	/**
	 * Default store path.
	 */
	public static final String DEFAULT_STORE_PATH = "D:\\NeoCrawler\\Default\\";
	public static final String DEFAULT_SEED_NAME = "Seeds.txt";
	public static final String DEFAULT_PARSER = "org.neocrawler.parser.SimpleParser";

	// ===== Database Related Configurations ===== //
	private String dbUrl;
	private String dbUserName;
	private String dbPassword;

	// ===== Connection Related Configurations ===== //
	private int connectTimeout = DEFAULT_CONNECT_TIMEOUT;
	private int getRequestTimeout = DEFAULT_GET_REQUEST_TIMEOUT;

	// ===== Crawling Thread Related Configurations ===== //
	private int threadPoolSize = DEFAULT_THREAD_POOL_SIZE;
	private long sleepTime = DEFAULT_SLEEP_TIME;
	private long sleepTimeRandom = DEFAULT_SLEEP_TIME_RANDOM;

	// ===== Proxy Related Configurations ===== //
	private boolean useProxyOrNot = DEFAULT_USE_PROXY_OR_NOT;
	private String proxyUrl;
	private int proxyPort;

	// ===== Storage Related Configurations ===== //
	private String storePath = DEFAULT_STORE_PATH;

	// ===== Seed Related Configurations ===== //
	private String seedPath = DEFAULT_STORE_PATH + DEFAULT_SEED_NAME;
	private String seedName = DEFAULT_SEED_NAME;

	// ===== Parser Related Configurations ===== //
	private String parserClassName = DEFAULT_PARSER;

	/**
	 * 
	 * Description:Default Constructor. To use NeoCrawler, the database
	 * connection is needed at least.
	 * 
	 * @author: Neo (neolimeng@gmail.com) Software Engineering Institute, Peking
	 *          University, China
	 * @version 1.0 2011-4-16 下午03:11:26
	 * @param dbUrl
	 * @param dbUserName
	 * @param dbPassword
	 */
	public Configuration(String dbUrl, String dbUserName, String dbPassword,
			String storePath) {
		this.dbUrl = dbUrl;
		this.dbUserName = dbUserName;
		this.dbPassword = dbPassword;
		this.useProxyOrNot = false;
		this.storePath = storePath;
	}

	public Configuration(String dbUrl, String dbUserName, String dbPassword,
			String proxyUrl, int proxyPort, String storePath) {
		this.dbUrl = dbUrl;
		this.dbUserName = dbUserName;
		this.dbPassword = dbPassword;
		this.useProxyOrNot = true;
		this.proxyPort = proxyPort;
		this.proxyUrl = proxyUrl;
		this.storePath = storePath;
	}

	public Configuration(String dbUrl, String dbUserName, String dbPassword,
			int connectTimeout, int getRequestTimeout, String proxyUrl,
			int proxyPort, String storePath) {
		this.dbUrl = dbUrl;
		this.dbUserName = dbUserName;
		this.dbPassword = dbPassword;
		this.useProxyOrNot = true;
		this.proxyPort = proxyPort;
		this.proxyUrl = proxyUrl;
		this.connectTimeout = connectTimeout;
		this.getRequestTimeout = getRequestTimeout;
		this.storePath = storePath;
	}

	public Configuration(String dbUrl, String dbUserName, String dbPassword,
			int connectTimeout, int getRequestTimeout, String proxyUrl,
			int proxyPort, long sleepTime, long sleepTimeRandom) {
		this.dbUrl = dbUrl;
		this.dbUserName = dbUserName;
		this.dbPassword = dbPassword;
		this.useProxyOrNot = true;
		this.proxyPort = proxyPort;
		this.proxyUrl = proxyUrl;
		this.connectTimeout = connectTimeout;
		this.getRequestTimeout = getRequestTimeout;
		this.sleepTime = sleepTime;
		this.sleepTimeRandom = sleepTimeRandom;
	}

	/**
	 * Description:
	 * 
	 * @param args
	 *            void
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

	public String getDbUrl() {
		return dbUrl;
	}

	public void setDbUrl(String dbUrl) {
		this.dbUrl = dbUrl;
	}

	public String getDbUserName() {
		return dbUserName;
	}

	public void setDbUserName(String dbUserName) {
		this.dbUserName = dbUserName;
	}

	public String getDbPassword() {
		return dbPassword;
	}

	public void setDbPassword(String dbPassword) {
		this.dbPassword = dbPassword;
	}

	public int getConnectTimeout() {
		return connectTimeout;
	}

	public void setConnectTimeout(int connectTimeout) {
		this.connectTimeout = connectTimeout;
	}

	public int getGetRequestTimeout() {
		return getRequestTimeout;
	}

	public void setGetRequestTimeout(int getRequestTimeout) {
		this.getRequestTimeout = getRequestTimeout;
	}

	public int getThreadPoolSize() {
		return threadPoolSize;
	}

	public void setThreadPoolSize(int threadPoolSize) {
		this.threadPoolSize = threadPoolSize;
	}

	public boolean isUseProxyOrNot() {
		return useProxyOrNot;
	}

	public void setUseProxyOrNot(boolean useProxyOrNot) {
		this.useProxyOrNot = useProxyOrNot;
	}

	public String getProxyUrl() {
		return proxyUrl;
	}

	public void setProxyUrl(String proxyUrl) {
		this.proxyUrl = proxyUrl;
	}

	public int getProxyPort() {
		return proxyPort;
	}

	public void setProxyPort(int proxyPort) {
		this.proxyPort = proxyPort;
	}

	public long getSleepTime() {
		return sleepTime;
	}

	public void setSleepTime(long sleepTime) {
		this.sleepTime = sleepTime;
	}

	public long getSleepTimeRandom() {
		return sleepTimeRandom;
	}

	public void setSleepTimeRandom(long sleepTimeRandom) {
		this.sleepTimeRandom = sleepTimeRandom;
	}

	public String getStorePath() {
		return storePath;
	}

	public void setStorePath(String storePath) {
		this.storePath = storePath;
	}

	public String getParserClassName() {
		return parserClassName;
	}

	public void setParserClassName(String parserClassName) {
		this.parserClassName = parserClassName;
	}

	public String getSeedPath() {
		return seedPath;
	}

	public void setSeedPath(String seedPath) {
		this.seedPath = seedPath;
	}

	public String getSeedName() {
		return seedName;
	}

	public void setSeedName(String seedName) {
		this.seedName = seedName;
	}

	public static String getDefaultSeedName() {
		return DEFAULT_SEED_NAME;
	}

}
